package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealAndDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @projectName: sky-take-out
 * @package: com.sky.mapper
 * @className: setmealMapper
 * @author: Eric
 * @description: TODO
 * @date: 2023/9/22 17:22
 * @version: 1.0
 */
@Mapper
public interface SetmealMapper {
    /**
     * 按id获取计数
     *
     * @param id id
     * @return {@link Integer}
     */
    Integer getCountById(Long id);

    /**
     * 选择pag
     *
     * @param setmeal 套餐
     * @return {@link List}<{@link Setmeal}>
     */
    List<Setmeal> selectPag(Setmeal setmeal);


    /**
     * 创建套餐
     *
     * @param setmealAndDish 套餐和菜肴
     */
    @AutoFill(OperationType.INSERT)
    void creatSetmeal(SetmealAndDish setmealAndDish);

    Integer getCountByName(String name);


    /**
     * 更改状态
     *
     * @param setmeal 套餐
     */
    @AutoFill(OperationType.UPDATE)
    void changeStatus(Setmeal setmeal);

    /**
     * 获取套餐
     *
     * @param id id
     * @return {@link SetmealVO}
     */
    @Select("select id, category_id, name, price, status, description, image, update_time from setmeal where id=#{id}")
    SetmealVO getSetmeal(Long id);


    /**
     * 按ids列表删除
     *
     * @param idsList ids列表
     */
    void deleteByIdsList(List<Long> idsList);

    /**
     * 按id计数
     *
     * @param idsList ids列表
     * @return {@link Integer}
     */
    Integer getCountByIds(List<Long> idsList);

    /**
     * 更新setmeal
     *
     * @param setmeal 套餐
     */
    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(SetmealAndDish setmeal);

    /**
     * 按类别id选择
     *
     * @param categoryId 类别id
     * @return {@link List}<{@link Setmeal}>
     */
    @Select("select id, category_id, name, price, status, description, image, create_time, update_time, " +
            "create_user, update_user from setmeal where category_id=#{categoryId}")
    List<Setmeal> selectByCategoryId(Long categoryId);
}

